package com.ycz.pattern.structure.flyweightpattern;

import java.util.HashMap;

/**
 * @Description
 * @ClassName ShapeFactory
 * @Author yanchengzhi
 * @date 2023.11.27 01:06
 */
public class ShapeFactory {

    private static final HashMap<String,Shape> map = new HashMap<>();

    public static Shape getCircle(String color) {
        Circle circle = (Circle) map.get(color);
        if(circle == null) {
            circle = new Circle(color);
            map.put(color,circle);
            System.out.println("创建圆的颜色：" + color);
        }
        return circle;
    }

}
